public class OfferHandler {
	/* Offer Handler does everything */
	void start(){
		
		while(true){
			String data = accept();
			
			char type = data.charAt(0); //for now
			
			switch(type){
			
				case BUY: 
					//add to AvailTrades
					handleBuy(data);
					break;
				case SELL:
					//add to AvailTrades
					handleSell(data);
					break;
				case ACCEPT:
					handleAccept(data);
					break;
				case WITHDRAW:
					handleWithdraw(data);
					break;
				default:
					//what?
					break;
					
			}
			
			
		}
	}
	
	String accept(){
		//deep TCP voodoo here
		return " ";
		
	}
	
	void decrementResourceAmt(String user, String ore, int amt){
		
		if(amt <=0)
			return;
		
		if(TraderHash.get(user) <0)
			return;
		
		int prevAmt = TraderHash.getResourceAmt(user, ore);
		
		if(prevAmt <=0)
			return;
		
		if(prevAmt > amt)
			return;
		
	    in_traders.setResource(user, ore, prevAmt-amt);
	    
	}
	
	
	void incrementResourceAmt(String user, String ore, int amt){
		if(amt <0)
			return;
		
		if(TraderHash.get(user) <0)
			return;
		
		int prevAmt = TraderHash.getResourceAmt(user, ore);
				
		TraderHash.setResource(user, ore, prevAmt+amt);
		
	}
	
	
}